<script setup>
import { ref, defineEmits } from 'vue'

const emit = defineEmits(['login'])

const form = ref({
  no: '',
  password: '',
  identity: '',
})
//通知父组件处理登录请求
const onSubmit = () => {
  emit('login', form.value)
}
</script>

<template>
  <el-form :model="form" label-width="auto">
    <el-form-item label="学号/工号">
      <el-input v-model="form.no" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.password" />
    </el-form-item>
    <el-form-item label="身份">
      <el-select v-model="form.identity" placeholder="请输入你的身份">
        <el-option label="教师" value="teacher" />
        <el-option label="学生" value="student" />
        <el-option label="管理员" value="admin" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
    </el-form-item>
  </el-form>
</template>

<style scoped lang="less">
.el-form {
  width: 50%;
  height: 100%;
  position: absolute;
  left: 400px;
  top: 0px;
  // border: 1px solid #ccc;
  border-left: 1px solid rgb(121, 220, 236);

  .el-form-item {
    margin-top: 70px;
    margin-left: 50px;
    width: 300px;
  }

  .el-button {
    margin-left: 120px;
    width: 100px;
    height: 40px;
    // background-color: rgb(121, 220, 236);
  }
}
</style>
